package carts.addition;

public class CalculateProcessor {
    private double unitBasedPrice = 0;
    private double volumeBasedPrice = 0;    // can be 0
    private int volumeNumber = 0;           // can be 0
    private int productCount = 0;


    private double getLiberalResult() {
        double result = 0;
        if (productCount >= volumeNumber) {
            result = (productCount / volumeNumber) * volumeBasedPrice;
        }
        result += (productCount % volumeNumber) * unitBasedPrice;
        return result;
    }

    public double getHadTimesResult() {
        return productCount * unitBasedPrice;
    }

    public double calculate(PrisingType prisingType) {
        if (prisingType == PrisingType.LIBERAL && volumeBasedPrice>0 && volumeNumber>0){
            return getLiberalResult();
        } else {
            return getHadTimesResult();
        }
    }




    public void setUnitBasedPrice(double unitBasedPrice) {
        this.unitBasedPrice = unitBasedPrice;
    }

    public void setVolumeBasedPrice(double volumeBasedPrice) {
        this.volumeBasedPrice = volumeBasedPrice;
    }

    public void setVolumeNumber(int volumeNumber) {
        this.volumeNumber = volumeNumber;
    }

    public void setProductCount(int productCount) {
        this.productCount = productCount;
    }
}
